#include <bits/stdc++.h>
using namespace std;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int a[101010],b,s=0;
        cin>>b;
        for(int j=0;j<b;j++){
            cin>>a[j];
        }
        sort(a+0,a+b);
        for(int j=1;j<b;j++){
            if(a[j]==a[j-1]){
                s+=a[j];
                a[j]=0;
                a[j-1]=0;
            }
        }
        cout<<s<<endl;
    }


    fclose(stdin);
    fclose(stdout);
    return 0;

}
